import { createRouter, createWebHistory } from 'vue-router'

const route = [{
    path: '/',
    name: 'Web',
    component: () => import('../views/Web/index.vue')
},
{
    path: '/admin',
    name: 'Admin',
    component: () => import('../views/Home/index.vue'),
    children: [
        {
            path: '/admin/users/personal',
            name: 'Personal',
            meta: {
                title: '个人中心'
            },
            component: () => import('../views/User/personal.vue')
        },{
            path: '/admin/users/password',
            name: 'Password',
            meta: {
                title: '修改密码'
            },
            component: () => import('../views/User/password.vue')
        },{
            path: '/admin/article',
            name: 'AdminArticle',
            meta: {
                title: '文章列表'
            },
            component: () => import('../views/Article/index.vue')
        },{
            path: '/admin/article/add',
            name: 'ArticleAdd',
            meta: {
                title: '发布文章'
            },
            component: () => import('../views/Article/add.vue')
        },{
            path: '/admin/comments',
            name: 'Comments',
            meta: {
                title: '评论管理'
            },
            component: () => import('../views/Comment/index.vue')
        },{
            path: '/admin/fans',
            name: 'Fans',
            meta: {
                title: '粉丝管理'
            },
            component: () => import('../views/Fans/index.vue')
        },{
            path: '/admin/star',
            name: 'Star',
            meta: {
                title: '点赞管理'
            },
            component: () => import('../views/Star/index.vue')
        }
    ]
},
{
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login/index.vue')
}]

const router = createRouter({
    history: createWebHistory(),
    routes: route,
    scrollBehavior() {
        return { 
            top: 0,
            left: 0,
            behavior: 'smooth'
        }
    }
})

export default router